// 创建公共状态管理对象
import { createStore } from 'redux'

import reducers from './reducer/index'
import { addTodo, setText } from './actions/index'

// 根据写好的reducer 创建了数据store 
let store = createStore(reducers)

console.log(store)
// getState() 获取所有的state
let mystate = store.getState();
console.log(mystate)

// 触发添加todos的actions方法
// store.dispatch(addTodo("吃饭"));
// store.dispatch(setText("睡觉"))

// 订阅state的变化
const unsubscribe = store.subscribe(() => {
  console.log(store.getState())
})